Thread: paintEnventargs^ e

  1. #1
    Registered User
    Join Date
    Jun 2009
    Posts
    3

    Angry paintEnventargs^ e

    Ok, this may be really stupid, but what argument is used in calling a function when the called function uses "PaintEventArgs^ e " as its argument?

  2. #2
    'Allo, 'Allo, Allo
    Join Date
    Apr 2008
    Posts
    639
    What are you trying to call? If it's some kind of form then the Invalidate member function is the easiest way to generate a paint event.

  3. #3
    Registered User
    Join Date
    Jun 2009
    Posts
    3

    Red face reply

    Guess I was trying to make it simple, but the answer is dependent on the information.
    My goal is to draw a test set of text on a GUI written using C++ d in Visual Studio.
    That said I am also in a learning curve . I did some digging around before all this and found:
    The generic form is:
    Code:
     public:
    void DrawString (
    	String^ s, 
    	Font^ font, 
    	Brush^ brush, 
    	PointF point
    )
    After coping/ pasting in to my do- nothing program/window- just to make it easy - .this example does not make the connection between the arguments in the parenthesis of the function : DrawStringPointF(ByVal e As PaintEventArgs) and calling this function - DrawStringPointF(?).
    For whomever replies, Could you supply a complete set of code from top to bottom that just "puts text in a GUI" in C++ using Visual Studio. If I have complete set of code, then I can figure the link.I have been reading text pages forteh last 3 days and have had to slowly build programs becasue the authors do't give it all at once.

    I am not asking for any help - seriously- but to show my entire problem. My other problem is reading a text file to display , sort, 3 ways and then redisplay.
    Example
    The following code example is designed for use with Windows Forms, and it requires PaintEventArgs^e, which is a parameter of the Paint event handler. The code performs the following actions:

    Creates a text string to draw.

    Defines the font as Arial (16pt).

    Creates a solid, black brush to draw with.

    Creates a point for the upper-left corner at which to draw the text.

    Code:
    C++  Copy Code 
    public:
       void DrawStringPointF( PaintEventArgs^ e )
       {
          // Create string to draw.
          String^ drawString = "Sample Text";
    
          // Create font and brush.
          System::Drawing::Font^ drawFont = gcnew System::Drawing::Font( "Arial",16 );
          SolidBrush^ drawBrush = gcnew SolidBrush( Color::Black );
    
          // Create point for upper-left corner of drawing.
          PointF drawPoint = PointF(150.0F,150.0F);
    
          // Draw string to screen.
          e->Graphics->DrawString( drawString, drawFont, drawBrush, drawPoint );
       }

  4. #4
    Registered User
    Join Date
    Jun 2009
    Posts
    3

    Red face

    update:
    Am I on target? if so ... look at the end
    I have the following
    Code:
    #pragma region Windows Form Designer generated code
    		/// <summary>
    		/// Required method for Designer support - do not modify
    		/// the contents of this method with the code editor.
    		/// </summary>
    		void InitializeComponent(void)
    		{
    			//
    			//Pauls input start
    			//
    			this->DrawStringPointF ->Size = System::Drawing::Size(200, 100);
    			//
    			//Pauls input end 
    ..
    .
    .
    .
    I am totally guessing at the part " -> Size = System :: Drawing::Size(200, 100);"
    can someone point me inthe right direction as to how to determine what the proper code

  5. #5
    'Allo, 'Allo, Allo
    Join Date
    Apr 2008
    Posts
    639
    You're meant to call it from the form's Paint method passing in the painteventargs you get from that:

    Right click your form
    Select properties
    Switch to the events view (that's the Lightning Bolt at the top)
    Double click on Paint, it's under Appearance

    Press enter and copy in:
    DrawStringPointF( e );

    Click after the "#pragma endregion", press enter and copy in all of the
    void DrawStringPointF( PaintEventArgs^ e )
    code.

    You should have something that looks like this

    Compile and run it.

  6. #6
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    FYI, that ain't C++ there.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

Popular pages Recent additions subscribe to a feed